package com.knowif.service;

import com.knowif.dao.BannerMapper;
import com.knowif.pojo.Banner;
import com.knowif.pojo.BannerExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ：Xh
 * @date ：Created in 2019/5/4 0004 21:28
 */
@Service
public class Banner_service {

    @Autowired
    private BannerMapper bannerMapper;

    /**
     * Banner条件查询
     * @param bannerExample
     * @return
     */
    public List<Banner> selectBanner(BannerExample bannerExample){
        return bannerMapper.selectByExample(bannerExample);
    }

    /**
     * 插入banner
     * @param banner
     * @return
     */
    public int saveBanner(Banner banner){
        return bannerMapper.insert(banner);
    }

    /**
     * 更新不为空的banner属性
     * @param banner
     * @return
     */
    public int updateBannerNotNull(Banner banner){
        return bannerMapper.updateByPrimaryKeySelective(banner);
    }

    /**
     * 更新所有banner属性
     * @param banner
     * @return
     */
    public int updateBanner(Banner banner){
        return bannerMapper.updateByPrimaryKey(banner);
    }

    /**
     * 删除banner
     * @param bannerId
     */
    public int deleteBanner(int bannerId){
        return bannerMapper.deleteByPrimaryKey(bannerId);
    }
}
